//新增产品表单验证
$("#editFormProduct").find("input,select").jqBootstrapValidation({
  preventSubmit: true,
  submitSuccess: function($form, event) {
      $.ajax({
        url: "/Handler/ProductHandler.ashx",
        type: "post",
        dataType: "json",
        data: {
          fun: "f_0002",
          id:$form.parent().attr("dataid"),
          data: JSON.stringify($("#editFormProduct").serializeObject())
        },
        beforeSend: function() {
          //数据加载冻屏
          $form.find("button[type=submit]").button('loading');
        },
        success: function(msg) {
          //数据加载完毕解除冻屏
          $form.find("button[type=submit]").button('reset');
          if(msg.r_code=="1"){
            toastr.success(msg.r_info, '系统提示：');
            //清空form表单
            $form.get(0).reset();
            $form.parent().modal('hide');
            $form.parent().remove();
            //刷新页面
            setTimeout(function () {
                window.location.href = window.location.href;
            }, 1000);
          }else if(msg.r_code=="0"){
            toastr.error(msg.r_info, '错误提示：');
          }
        }
      });
      event.preventDefault();
  },
  filter: function() {
      return $(this).is(":visible");
  }
});

//产品类型赋值
$("#Product_TypeID").on("change",function(){
  $("#Product_TypeName").val($(this).find("option:selected").text());
}).trigger("change");